﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 报表统计表
/// </summary>
[Table("ReportStatistic")]
[Index("ReportPeriod", "MerchantId", "StoreId", "PaymentCodeId", "ReportType", Name = "idx_ReportPeriod_Merchant", IsUnique = true)]
public partial class ReportStatistic
{
    /// <summary>
    /// 报表统计ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 报表类型(1=日报,2=周报,3=月报)
    /// </summary>
    public int ReportType { get; set; }

    /// <summary>
    /// 报表日期
    /// </summary>
    public DateOnly ReportDate { get; set; }

    /// <summary>
    /// 报表周期(如:2025-07-01,2025第27周,2025-07)
    /// </summary>
    [StringLength(20)]
    public string ReportPeriod { get; set; } = null!;

    /// <summary>
    /// 商户ID
    /// </summary>
    [StringLength(32)]
    public string MerchantId { get; set; } = null!;

    /// <summary>
    /// 门店ID
    /// </summary>
    [StringLength(32)]
    public string? StoreId { get; set; }

    /// <summary>
    /// 收款码ID
    /// </summary>
    [StringLength(32)]
    public string? PaymentCodeId { get; set; }

    /// <summary>
    /// 收款金额
    /// </summary>
    public long ReceiptAmount { get; set; }

    /// <summary>
    /// 退款金额
    /// </summary>
    public long RefundAmount { get; set; }

    /// <summary>
    /// 净金额(收款-退款)
    /// </summary>
    public long NetAmount { get; set; }

    /// <summary>
    /// 分账金额
    /// </summary>
    public long DividedAmount { get; set; }

    /// <summary>
    /// 结算金额
    /// </summary>
    public long SettledAmount { get; set; }

    /// <summary>
    /// 收款订单数
    /// </summary>
    public int ReceiptOrderCount { get; set; }

    /// <summary>
    /// 退款订单数
    /// </summary>
    public int RefundOrderCount { get; set; }

    /// <summary>
    /// 顾客数
    /// </summary>
    public int CustomerCount { get; set; }

    /// <summary>
    /// 支付方式统计(JSON格式)
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? PaymentMethodStat { get; set; }

    /// <summary>
    /// 优惠统计(JSON格式)
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? DiscountStat { get; set; }

    /// <summary>
    /// 近四周收入对比(JSON格式)
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? WeeklyComparison { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    public string? ExtraProperties { get; set; }

    /// <summary>
    /// 并发标记
    /// </summary>
    [StringLength(40)]
    public string? ConcurrencyStamp { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }
}
